/**
 * This is my code.
 *
 * $Id$
 */
package fi.jab.esb.config.xml.impl;

import fi.jab.esb.config.xml.SqlProviderType;
import fi.jab.esb.config.xml.XmlPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Sql Provider Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fi.jab.esb.config.xml.impl.SqlProviderTypeImpl#getDatasource <em>Datasource</em>}</li>
 *   <li>{@link fi.jab.esb.config.xml.impl.SqlProviderTypeImpl#getDriver <em>Driver</em>}</li>
 *   <li>{@link fi.jab.esb.config.xml.impl.SqlProviderTypeImpl#getPassword <em>Password</em>}</li>
 *   <li>{@link fi.jab.esb.config.xml.impl.SqlProviderTypeImpl#isTransacted <em>Transacted</em>}</li>
 *   <li>{@link fi.jab.esb.config.xml.impl.SqlProviderTypeImpl#getUrl <em>Url</em>}</li>
 *   <li>{@link fi.jab.esb.config.xml.impl.SqlProviderTypeImpl#getUsername <em>Username</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SqlProviderTypeImpl extends BusProviderImpl implements SqlProviderType
{
  /**
   * The default value of the '{@link #getDatasource() <em>Datasource</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDatasource()
   * @generated
   * @ordered
   */
  protected static final String DATASOURCE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDatasource() <em>Datasource</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDatasource()
   * @generated
   * @ordered
   */
  protected String datasource = DATASOURCE_EDEFAULT;

  /**
   * The default value of the '{@link #getDriver() <em>Driver</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDriver()
   * @generated
   * @ordered
   */
  protected static final String DRIVER_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDriver() <em>Driver</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDriver()
   * @generated
   * @ordered
   */
  protected String driver = DRIVER_EDEFAULT;

  /**
   * The default value of the '{@link #getPassword() <em>Password</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPassword()
   * @generated
   * @ordered
   */
  protected static final String PASSWORD_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getPassword() <em>Password</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPassword()
   * @generated
   * @ordered
   */
  protected String password = PASSWORD_EDEFAULT;

  /**
   * The default value of the '{@link #isTransacted() <em>Transacted</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isTransacted()
   * @generated
   * @ordered
   */
  protected static final boolean TRANSACTED_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isTransacted() <em>Transacted</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isTransacted()
   * @generated
   * @ordered
   */
  protected boolean transacted = TRANSACTED_EDEFAULT;

  /**
   * This is true if the Transacted attribute has been set.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   * @ordered
   */
  protected boolean transactedESet;

  /**
   * The default value of the '{@link #getUrl() <em>Url</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUrl()
   * @generated
   * @ordered
   */
  protected static final String URL_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getUrl() <em>Url</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUrl()
   * @generated
   * @ordered
   */
  protected String url = URL_EDEFAULT;

  /**
   * The default value of the '{@link #getUsername() <em>Username</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUsername()
   * @generated
   * @ordered
   */
  protected static final String USERNAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getUsername() <em>Username</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUsername()
   * @generated
   * @ordered
   */
  protected String username = USERNAME_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SqlProviderTypeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return XmlPackage.Literals.SQL_PROVIDER_TYPE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDatasource()
  {
    return datasource;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDatasource(String newDatasource)
  {
    String oldDatasource = datasource;
    datasource = newDatasource;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.SQL_PROVIDER_TYPE__DATASOURCE, oldDatasource, datasource));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDriver()
  {
    return driver;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDriver(String newDriver)
  {
    String oldDriver = driver;
    driver = newDriver;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.SQL_PROVIDER_TYPE__DRIVER, oldDriver, driver));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getPassword()
  {
    return password;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPassword(String newPassword)
  {
    String oldPassword = password;
    password = newPassword;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.SQL_PROVIDER_TYPE__PASSWORD, oldPassword, password));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isTransacted()
  {
    return transacted;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTransacted(boolean newTransacted)
  {
    boolean oldTransacted = transacted;
    transacted = newTransacted;
    boolean oldTransactedESet = transactedESet;
    transactedESet = true;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.SQL_PROVIDER_TYPE__TRANSACTED, oldTransacted, transacted, !oldTransactedESet));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void unsetTransacted()
  {
    boolean oldTransacted = transacted;
    boolean oldTransactedESet = transactedESet;
    transacted = TRANSACTED_EDEFAULT;
    transactedESet = false;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.UNSET, XmlPackage.SQL_PROVIDER_TYPE__TRANSACTED, oldTransacted, TRANSACTED_EDEFAULT, oldTransactedESet));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isSetTransacted()
  {
    return transactedESet;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getUrl()
  {
    return url;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setUrl(String newUrl)
  {
    String oldUrl = url;
    url = newUrl;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.SQL_PROVIDER_TYPE__URL, oldUrl, url));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getUsername()
  {
    return username;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setUsername(String newUsername)
  {
    String oldUsername = username;
    username = newUsername;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.SQL_PROVIDER_TYPE__USERNAME, oldUsername, username));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case XmlPackage.SQL_PROVIDER_TYPE__DATASOURCE:
        return getDatasource();
      case XmlPackage.SQL_PROVIDER_TYPE__DRIVER:
        return getDriver();
      case XmlPackage.SQL_PROVIDER_TYPE__PASSWORD:
        return getPassword();
      case XmlPackage.SQL_PROVIDER_TYPE__TRANSACTED:
        return isTransacted() ? Boolean.TRUE : Boolean.FALSE;
      case XmlPackage.SQL_PROVIDER_TYPE__URL:
        return getUrl();
      case XmlPackage.SQL_PROVIDER_TYPE__USERNAME:
        return getUsername();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case XmlPackage.SQL_PROVIDER_TYPE__DATASOURCE:
        setDatasource((String)newValue);
        return;
      case XmlPackage.SQL_PROVIDER_TYPE__DRIVER:
        setDriver((String)newValue);
        return;
      case XmlPackage.SQL_PROVIDER_TYPE__PASSWORD:
        setPassword((String)newValue);
        return;
      case XmlPackage.SQL_PROVIDER_TYPE__TRANSACTED:
        setTransacted(((Boolean)newValue).booleanValue());
        return;
      case XmlPackage.SQL_PROVIDER_TYPE__URL:
        setUrl((String)newValue);
        return;
      case XmlPackage.SQL_PROVIDER_TYPE__USERNAME:
        setUsername((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case XmlPackage.SQL_PROVIDER_TYPE__DATASOURCE:
        setDatasource(DATASOURCE_EDEFAULT);
        return;
      case XmlPackage.SQL_PROVIDER_TYPE__DRIVER:
        setDriver(DRIVER_EDEFAULT);
        return;
      case XmlPackage.SQL_PROVIDER_TYPE__PASSWORD:
        setPassword(PASSWORD_EDEFAULT);
        return;
      case XmlPackage.SQL_PROVIDER_TYPE__TRANSACTED:
        unsetTransacted();
        return;
      case XmlPackage.SQL_PROVIDER_TYPE__URL:
        setUrl(URL_EDEFAULT);
        return;
      case XmlPackage.SQL_PROVIDER_TYPE__USERNAME:
        setUsername(USERNAME_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case XmlPackage.SQL_PROVIDER_TYPE__DATASOURCE:
        return DATASOURCE_EDEFAULT == null ? datasource != null : !DATASOURCE_EDEFAULT.equals(datasource);
      case XmlPackage.SQL_PROVIDER_TYPE__DRIVER:
        return DRIVER_EDEFAULT == null ? driver != null : !DRIVER_EDEFAULT.equals(driver);
      case XmlPackage.SQL_PROVIDER_TYPE__PASSWORD:
        return PASSWORD_EDEFAULT == null ? password != null : !PASSWORD_EDEFAULT.equals(password);
      case XmlPackage.SQL_PROVIDER_TYPE__TRANSACTED:
        return isSetTransacted();
      case XmlPackage.SQL_PROVIDER_TYPE__URL:
        return URL_EDEFAULT == null ? url != null : !URL_EDEFAULT.equals(url);
      case XmlPackage.SQL_PROVIDER_TYPE__USERNAME:
        return USERNAME_EDEFAULT == null ? username != null : !USERNAME_EDEFAULT.equals(username);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (datasource: ");
    result.append(datasource);
    result.append(", driver: ");
    result.append(driver);
    result.append(", password: ");
    result.append(password);
    result.append(", transacted: ");
    if (transactedESet) result.append(transacted); else result.append("<unset>");
    result.append(", url: ");
    result.append(url);
    result.append(", username: ");
    result.append(username);
    result.append(')');
    return result.toString();
  }

} //SqlProviderTypeImpl
